//
//  XRmenuCoreData.h
//  XRmenu
//
//  Created by Gao Yan on 11-11-23.
//  Copyright 2011年 foxhis. All rights reserved.
//
#import <CoreData/CoreData.h>
#import <Foundation/Foundation.h>
#import "AllInclude.h"

@class XRmenuError;
@class PluPlu;
@class DishOrder;

@class Product;
@interface XRmenuCoreData : NSObject {

}
#pragma mark XRmenu
+(NSMutableArray*) getAllCommendPlu;
+(NSMutableArray*) getAllPluMenu;
+(NSMutableArray*) getAllDishOrder;
+(NSMutableArray*) getAllPluTable;
+(NSMutableArray*) getAllPluPlu;
    
#pragma mark XRmenu我的点单
+(void) insertNewDishOrder:(PluPlu*)item Error:(XRmenuError**)outError;
+(void) updateDishOrderNum:(DishOrder*)item Increase:(NSNumber*)numb Error:(XRmenuError**)outError;
+(void) deleteAllDishOrder:(XRmenuError**)outError;
+(void) deleteOneDishOrder:(DishOrder*)item Error:(XRmenuError**)outError;

#pragma mark 数据操作基础方法
+(NSMutableArray *) getObjectsMOC:(NSString*)entityName 
                          SortKey:(NSString*)sortKey 
                    SortAscending:(BOOL)sortAscending 
             ManagedObjectContext:(NSManagedObjectContext *)managedObjectContext;
+(NSMutableArray *) searchObjectsMOC:(NSString*)entityName Predicate:(NSPredicate *)predicate SortKey:(NSString*)sortKey SortAscending:(BOOL)sortAscending ManagedObjectContext:(NSManagedObjectContext *)MOC;
+(NSMutableArray *) getObjectsFromContext:(NSString*)entityName SortKey:(NSString*)sortKey SortAscending:(BOOL)sortAscending;
+(NSMutableArray *) searchObjectsInContext:(NSString*)entityName Predicate:(NSPredicate *)predicate SortKey:(NSString*)sortKey SortAscending:(BOOL)sortAscending;
+(NSMutableArray *)searchObjectsInContext:(NSString*)entityName Predicate:(NSPredicate *)predicate SortKeys:(NSArray*)sortKeys SortAscending:(BOOL)sortAscending;

+(void) deleteAllObjects: (NSString *) entityDescription ManagedObjectContext:(NSManagedObjectContext *)MOC;
+(BOOL) clearDBManagedObjectContext:(NSManagedObjectContext *)MOC;

#pragma mark Catalogs相关操作
+(NSMutableArray*) getAllCatalogsByBookID:(NSString*)bkid;
+(NSMutableArray*) getAllTagsWithLanguage;

#pragma mark 菜单数据基本操作
+(NSString*) createNewSaleOrder:(XRmenuError**)outError;
+(void) insertNewOrderProduct:(Product*)item Error:(XRmenuError**)outError;
+(void) updateProductNum:(Product*)item Increase:(NSNumber*)numb Error:(XRmenuError**)outError;
+(void) clearAllSaleProduct:(NSString*)orderno Error:(XRmenuError**)outError;
+(void) clearProduct:(Product*)item Error:(XRmenuError**)outError;

+(NSMutableArray*) getAllOrderedProduct;

#pragma mark 数据检索
+(NSMutableArray*) searchByString:(NSString*)searchtxt;
@end
